package com.heima;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Date;
import java.util.Scanner;

/**
 * 将输入的生日转换为毫秒值
 * 获取当地时间的毫秒值
 * 通过两者之差转为天数毫秒/1000/1000/60/60/24
 */
public class BirthToNow {
    public static void main(String[] args) throws ParseException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的生日:(格式为yyyy-MM-dd)");
        String birthDay = sc.next();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        //将输入内容转换为Date对象
        Date date = sdf.parse(birthDay);
        //将date对象获取为毫秒值
        long time = date.getTime();
        //获取当地时间
        Date now = new Date();
        long nowTime = now.getTime();
        long l = (nowTime - time)/1000/60/60/24;
        System.out.println(l+"天");

    }
}
